package mi.payment.db.dao;

import android.database.sqlite.SQLiteDatabase;

import mi.payment.MyApplication;

/**
 * 数据库管理工具
 */
public class DBManager {

    private DaoMaster.DevOpenHelper devOpenHelper;

    private static DBManager instance;

    private static final String DB_NAME = "sm_pay.db";

    private DBManager() {
        devOpenHelper = new DBOpenHelper(MyApplication.getInstance(), DB_NAME);
    }

    public static DBManager getInstance() {
        if (instance == null) {
            instance = new DBManager();
        }
        return instance;
    }

    public SQLiteDatabase getWritableDatabase() {
        if (devOpenHelper == null) {
            devOpenHelper = new DBOpenHelper(MyApplication.getInstance(), DB_NAME);
        }
        SQLiteDatabase db = devOpenHelper.getWritableDatabase();
        return db;
    }

}
